package cn.dz.domain.mp.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Component;

/**
 * @ClassName GetJsonNode
 * @package: cn.dz.domain.mp.utils
 * @Description TODO
 * @Author dz
 * @Date 2025/1/10 12:50
 * @Version 1.0
 **/
@Component
public class GetJsonNode {


    public JsonNode getJsonNode(String s) {
        try {
            // 创建 ObjectMapper 实例
            ObjectMapper objectMapper = new ObjectMapper();
            // 创建 JSON 数据
            String jsonString = "{\"age\": 24, \"intro\": \"英文老师\", \"gender\": \"female\"}";
            // 将 JSON 字符串解析为 JsonNode 对象
            JsonNode infoNode = objectMapper.readTree(jsonString);
            return infoNode;
        } catch (JsonProcessingException e) {
            throw new RuntimeException(e);
        }
    }

}
